package com.kindnesslibrary.util;

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;

/**
 * Created by lenovo on 2017/7/12.
 */
public class EnableGridManager extends GridLayoutManager {

    private boolean isScrollEnabled = false;

    public EnableGridManager(Context context, int spanCount) {
        super(context, spanCount);
    }

    /**
     * 是否支持滑动
     * @param flag
     */
    public void setScrollEnabled(boolean flag) {
        this.isScrollEnabled = flag;
    }

    @Override
    public boolean canScrollVertically() {
        //isScrollEnabled：recyclerview是否支持滑动
        //super.canScrollVertically()：是否为竖直方向滚动
        return isScrollEnabled && super.canScrollVertically();
    }
}
